<?php

namespace app\modules\cart\controllers;

use Yii;
use yii\web\Controller;
use common\models\Tools;
use common\models\Goods;
use common\models\GoodsPackage;
use common\models\Cart;

/**
 * Default controller for the `cart` module
 */
class DefaultController extends Controller
{
	public $leftmenu;
    /**
     * 购物车列表
     * @return string
     */
    public function actionIndex()
    {
		
        if (Yii::$app->user->isGuest) {
            Tools::get_show_msg('/site/login', '请先登录！', 0, 3);
        }
        $condition = [];
        $page_no = Tools::GetSafeParam('page_no', 1, 0);
        
        $userid = Yii::$app->user->identity->id;
        $data = Cart::getUserCartList($userid,$condition,$page_no);
        
        $page = Tools::showCmPager($page_no, $data['perpage'], $data['total'],$condition);
        $this->layout = "/personal";
		$this->leftmenu='cart';
        // echo "<pre>";
        // print_r($data);exit;
        
        return $this->render('index',[
            'data' => $data,
            'page' => $page,
			'backend_server' => Yii::$app->params['backend_server'],
            'condition' => $condition,
            ]);
    }
}
